import { Component, OnInit, Inject } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA, MatDialog } from '@angular/material/dialog';

@Component({
  selector: 'app-patriotic',
  templateUrl: './patriotic.component.html',
  styleUrls: [
    './patriotic.component.less',
    '../index/index.component.less'
  ]
})
export class PatrioticComponent implements OnInit {

  constructor(public dialog: MatDialog) { }

  ngOnInit() {
  }

  openDialog(data): void {
    console.log(data);
    
    const dialogRef = this.dialog.open(PatrioticDialog, {
      width: '250px',
      data: data
    });
  }

  data = [
    {
      title:"北京市",
      data:[
        {
          title:"国家博物馆",
          image:"http://photocdn.sohu.com/20141017/Img405204315.jpg",
          link:"http://www.chnmuseum.cn/"
        },
        {
          title:"中国人民革命军事博物馆",
          image:"http://img.pconline.com.cn/images/photoblog/8/4/3/0/8430175/20098/1/1249134912606_mthumb.jpg",
          link:"http://www.jb.mil.cn/"
        },
        {
          title:"中国人民抗日战争纪念馆",
          image:"http://s3.sinaimg.cn/middle/7132882btc9c47364fe52&690",
          link:"http://www.1937china.com/"
        },
      ]
    },
    {
      title:"四川省",
      data:[
        {
          title:"邓小平故居",
          image:"http://5b0988e595225.cdn.sohucs.com/images/20170911/f06fb15817f94957973d3a19089b871f.jpeg",
          link:"http://www.dxpgl.cn/"
        },
        {
          title:"黄继光纪念馆",
          image:"http://5b0988e595225.cdn.sohucs.com/images/20171017/a281a1c2fb834be0acb1acd1ae8cabba.jpg",
          link:"http://www.hjgjng.net/"
        },
      ]
    }
  ]
}

@Component({
  selector: 'patriotic-dialog',
  templateUrl: 'patriotic.dialog.html',
})
export class PatrioticDialog {
  constructor(
    public dialogRef: MatDialogRef<PatrioticDialog>,
    @Inject(MAT_DIALOG_DATA) public data: any) {
    }

  onNoClick(): void {
    this.dialogRef.close();
  }

  onClick():void {
    window.open(this.data.link)
    this.dialogRef.close();
  }

}
